package com.cyjt.operation.adapter;

import java.util.List;

import com.cyjt.operation.R;
import com.cyjt.operation.bean.InspectionTimeInfo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

/**
 * 动态节点列表的Adapter
 * 
 * @author LTP
 * 
 */
public class InspectionAreaAdapter extends ArrayAdapter<InspectionTimeInfo> {

	/** list_view_item的资源 */
	private int resourceId;

	/**
	 * @param context
	 *            上下文
	 * @param resource
	 *            list_view_item的资源
	 * @param objects
	 *            对象的List集合
	 */
	public InspectionAreaAdapter(Context context, int resource, List<InspectionTimeInfo> objects) {
		super(context, resource, objects);
		resourceId = resource;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		InspectionTimeInfo inspectionTimeInfo = getItem(position);
		ViewHolder viewHolder;
		if (convertView == null) {
			convertView = LayoutInflater.from(getContext()).inflate(resourceId, null);
			viewHolder = new ViewHolder();
			viewHolder.textView_item_for_inspection_area = (TextView) convertView
					.findViewById(R.id.textView_item_for_inspection_area);
			viewHolder.textView_item_for_area_name = (TextView) convertView
					.findViewById(R.id.textView_item_for_area_name);
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		viewHolder.textView_item_for_area_name.setText(inspectionTimeInfo.getTitle() + "");
		viewHolder.textView_item_for_inspection_area.setText(inspectionTimeInfo.getAreaId() + "");
		return convertView;
	}

	class ViewHolder {
		TextView textView_item_for_inspection_area, textView_item_for_area_name;
	}
}
